﻿<%@  Language="C#" MasterPageFile="~/Masters/Basic.Master" AutoEventWireup="true" CodeBehind="ProductOrderList.aspx.cs" Inherits="PMS.UI.PM.ProductOrderList" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        $(function () {
            var height = $("#divTotal").height();
            var master = $("#master").height();
            var content = parseFloat(height) - parseFloat(master) - 30;
            $("#tbList").css("height", content);
        });
    </script>
    <script type="text/javascript">
        $(function () {
            //   $('#btnModify').linkbutton('disable');
            $("#tbList").datagrid({
                url: '/Logic/PM/ProductOrderAjax.aspx?method=GetProductOrderList',
                loadMsg: '数据加载中请稍后……',
                fitColumns: false,
                pagination: true,
                queryParams: com.serializeSearchArray("form1"),
                rownumbers: true,
                idField: "ID",
                singleSelect: true,
                pageSize: 20,
                pageList: [20, 50, 100],
                striped: true,
                frozenColumns: [[{ field: 'ck', checkbox: true, width: 30 },
                 { field: 'ID', title: 'ID', align: "center", width: 40 },

                 {
                     field: 'IsComplete', title: '是否完成', align: "center", width: 60,
                     formatter: function (value, row, Index) {
                         return com.getArrayText([{ value: "0", text: "未完成" }, { value: "1", text: "已完成" }], value);
                     },
                     styler: function (value, row, index) {
                         if (value == "1") {
                             return 'background-color:#00EC00;color:black';
                         }
                     }
                 },
                 {
                     field: 'IsUrgent', title: '是否紧急', align: "center", width: 60,
                     editor:
                         {
                             type: "combobox",
                             options:
                                {
                                    data: StaticCombo.isOrderUrgent,
                                    valueField: 'value',
                                    textField: 'text',
                                    required: true
                                }
                         },
                     formatter: function (value, row, Index) {
                         return com.getArrayText(StaticCombo.isOrderUrgent, value);
                     },
                     styler: function (value, row, index) {
                         if (value == "1") {
                             return 'color:red';
                         }
                     }
                 },
                  {
                      field: 'State', title: '状态', align: "center", width: 80,
                      formatter: function (value, row, Index) {
                          return com.getArrayText(StaticCombo.QuotState, value);
                      }
                  },
                 {
                     field: 'Code', title: '生产订单号 ', align: "center", width: 100
                 },
                
                  {
                      field: 'QuotationCode', title: '报价单号', align: "center", width: 100
                  },
                 {
                     field: 'ContractCode', title: '合同编号', align: "center", width: 100
                 },
                 {
                     field: 'CustomerName', title: '客户单位名称', align: "center", width: 100,
                     formatter: function (value, row, index) {
                         //鼠标放在文本处自动显示tooltip
                         return '<span title=' + value + '>' + value + '</span>';
                     }
                 },
                ]],
                columns: [[
                 {
                     field: 'OrderDate', title: '下单日期', align: "center", width: 100, sortable: true, editor: {
                         type: "datebox",
                         options: {}
                     }
                 },
                 {
                     field: 'ReleaseDate', title: '交货日期', align: "center", width: 100, sortable: true, editor: {
                         type: "datebox",
                         options: {}
                     }
                 },
                 {
                     field: 'OrderNum', title: '订货数量', align: "center", width: 60
                 },
                 {
                     field: 'InMakingNum', title: '在制数量', align: "center", width: 60
                 },
                {
                    field: 'CompletedNum', title: '配气数量', align: "center", width: 60
                },
               {
                   field: 'QulifiedNum', title: '合格数量', align: "center", width: 60
               },
                {
                    field: 'UnQulifiedNum', title: '不合格数', align: "center", width: 60,
                    styler: function (value, row, index) {
                        if (value > 0) {
                            return 'background-color:red;color:black';
                        }
                    }
                },
                {
                    field: 'StorageNum', title: '入库数量', align: "center", width: 60
                },
                {
                    field: 'DeliveredNum', title: '发货数量', align: "center", width: 60
                },
                {
                    field: 'ReceiveAddress', title: '送货地址', align: "center", width: 100
                },
                {
                    field: 'InvoiceAddress', title: '收发票地址', align: "center", width: 100
                },
                 {
                     field: 'FillPerson', title: '制单人', align: "center", width: 100
                 },
                 {
                     field: 'FillDate', title: '制单日期', align: "center", width: 120
                 },

                  {
                      field: 'CompleteDate', title: '完成日期', align: "center", width: 100
                  },
                {
                    field: 'Note', title: '备注', align: "center", width: 100, editor: {
                        type: "validatebox",
                        options: {}
                    }
                }]],
                onAfterEdit: function (rowIndex, rowData, changes) {
                    if (editAction == "edit") {
                        com.ajax({
                            url: "/Logic/PM/ProductOrderAjax.aspx?method=EditProductOrder",
                            data: rowData,
                            success: function (data) {
                                com.message(data.state, data.msg, function () { $("#tbList").datagrid("reload"); });
                            }
                        });
                    }
                    editRow = undefined;
                },
                onCancelEdit: function (rowIndex, rowData) {
                    $("#tbList").datagrid("rejectChanges");
                },
                onDblClickRow: function (rowIndex, rowData) {
                    top.wrapper.addTab("生产订单细则", "/UI/PM/ProductOrderDetail.aspx?action=edit&ID=" + rowData.ID + "&quotID=" + rowData.QuotationID)
                }
            });

        });

    </script>

    <script type="text/javascript">
        editRow = undefined;
        editAction = undefined;

        //编辑
        function funcEdit() {
            var row = $('#tbList').datagrid('getSelected');

            if (row) {
                if (editRow != undefined) {
                }
                else {
                    var index = $("#tbList").datagrid('getRowIndex', row);
                    $("#tbList").datagrid('beginEdit', index);
                    editAction = "edit";
                    editRow = index;
                    rowData = $("#tbList").datagrid("getSelected");
                }
            }
            else {
                com.message("information", "请选中一行");
            }
        }

        //查询
        function funcSearch() {
            var para = com.serializeSearchArray("form1");
            $("#tbList").datagrid("load", para);
            editRow = undefined;
            editAction = undefined;
        }

        //删除
        function funcRemove() {
            var row = $('#tbList').datagrid('getSelected');
            if (row) {
                $.messager.confirm('确认对话框', '您确定删除该生产订单吗？', function (r) {
                    if (r) {
                        com.ajax({
                            url: "/Logic/PM/ProductOrderAjax.aspx?method=DelProductOrder",
                            data: { ID: row.ID, QuotationID: row.QuotationID },
                            success: function (data) {
                                com.message(data.state, data.msg, function () { $("#tbList").datagrid("reload"); })
                            }
                        });
                    }
                });
            }
            else {
                com.message("information", "请选中一行");
            }
            editRow = undefined;
            editAction = undefined;
        }

        //取消编辑
        function funcCancel() {
            $('#tbList').datagrid("cancelEdit", editRow);
            editRow = undefined;
            editAction = undefined;
        }

        //重置
        function funcReload() {
            $("#form1").form("reset");
            var para = com.serializeSearchArray("form1");
            $("#tbList").datagrid("load", para);
            editRow = undefined;
            editAction = undefined;
        }

        //保存
        function funcSave() {
            $('#tbList').datagrid('endEdit', editRow);
        }

    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="divTotal" style="height: 100%; width: 100%">

        <div id="master" class="container_16" style="height: auto">
            <form id="form1">
                <div class="grid_2 sealbl" style="width: 100px">
                    生产订单号 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="Code" name="Code" data-cp="co" />
                </div>
                <div class="grid_2 sealbl" style="text-align: right;">
                    单位名称 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" class="easyui-combobox" id="CustomerName" name="CustomerName" data-cp="=" data-options="valueField:'text',textField:'text',url:'/Logic/BD/CompanyAjax.aspx?method=GetAllCompanyNameList',panelHeight:'auto'" />
                </div>
                <div class="grid_2 sealbl" style="text-align: right;">
                    状态 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" class="easyui-combobox" id="State" name="State" data-cp="=" data-options="valueField:'value',textField:'text',data:StaticCombo.QuotStateQuery,panelHeight:'auto'" />
                </div>
                <div class="grid_2 sealbl" style="text-align: right;">
                    是否紧急 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" class="easyui-combobox" id="IsUrgent" name="IsUrgent" data-cp="=" data-options="valueField:'value',textField:'text',data:StaticCombo.isOrderUrgentQuery,panelHeight:'auto'" />
                </div>

                <div class="Clear"></div>
                <div class="grid_2 sealbl" style="width: 100px">
                    下单日期从:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="startOrderDate" name="startOrderDate" data-cp="str>=" class="easyui-datebox" />
                </div>
                <div class="grid_2 sealbl">
                    到:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="endOrderDate" name="endOrderDate" data-cp="str<=" class="easyui-datebox" />
                </div>
                <%--<div class="grid_2 sealbl" style="width: 100px">
                    交货日期从:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="startReleaseDate" name="startReleaseDate" data-cp="str>=" class="easyui-datebox" />
                </div>
                <div class="grid_2 sealbl">
                    到:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="endReleaseDate" name="endReleaseDate" data-cp="str<=" class="easyui-datebox" />
                </div>--%>
                <div class="grid_2 sealbl" style="text-align: right;">
                    是否完成 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" class="easyui-combobox" id="IsComplete" name="IsComplete" data-cp="=" 
                      data-options="valueField:'value',textField:'text',
                        data:[{ value:'', text: '全部' },{ value: '0', text: '未完成' }, { value: '1', text: '已完成' }],panelHeight:'auto'" />
                </div>
            </form>
        </div>
        <table id="tbList" title="生产订单信息表 " style="width: 100%">
        </table>
    </div>
</asp:Content>
